document.ready(function() {
    queryKey('ok');
});

function queryKey(flag) {
    openLoad();

    var param = {};
    param.ctrl = 'other';
    param.func = 'getSortationList2';

    sendAjax(param, function(result) {
        sortation.list = result.sortationList;
        setHtml('listCount', result.listCount);

        setDisplay('mainBg', '');
        closeLoad();
    });
}

function saveSortation() {
    if (isEmpty('keyword1') || isWicked('keyword1')) {
        showTip('名称格式错误');
        return;
    }

    var param = {};
    param.ctrl = 'other';
    param.func = 'saveSortation';
    param.name = getAjaxValue('keyword1');

    sendAjax(param, function(result) {
        setValue('keyword1', '');
        queryKey('ok');
    });
}

function openSortation(id, name) {
    setValue('tempid', id);
    openConfirm('确定开启 【' + name + '】 吗？', null, function() {
        var param = {};
        param.ctrl = 'other';
        param.func = 'openSortation';
        param.sortationid = getAjaxValue('tempid');

        sendAjax(param, function(result) {
            queryKey('ok');
        });
    });
}

function deleteSortation(id, name) {
    setValue('tempid', id);
    openConfirm('确定删除 【' + name + '】 吗？', null, function() {
        var param = {};
        param.ctrl = 'other';
        param.func = 'deleteSortation';
        param.sortationid = getAjaxValue('tempid');

        sendAjax(param, function(result) {
            queryKey('ok');
        });
    });
}